VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsLoadIRP3c"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Public Function SaveIRP3C(ByVal Username As String, ByVal sNoTaxRefNoRsn As String, ByVal sNoTaxRefNoText As String, _
                          ByVal nIncomeTaxReferenceNo As String, ByVal nRSAID As String, ByVal sOtherID As String, _
                          ByVal sSurname As String, ByVal sInitials As String, ByVal sFirstNames As String, _
                          ByVal dtBirthDate As String, _
                          ByVal sPost1 As String, ByVal sPost2 As String, ByVal sPost3 As String, ByVal sPost4 As String, ByVal sPostCode As String, _
                          ByVal sHome1 As String, ByVal sHome2 As String, ByVal sHome3 As String, ByVal sHome4 As String, ByVal sHomeCode As String, _
                          ByVal nTaxYear As String, ByVal lstRFD As String, _
                          ByVal sEmailTo As String, _
                          ByVal nEmpID As String, _
                          ByVal nEmployeeNo As String, _
                          ByVal nTaxPayersAnnualIncome As String, _
                          ByVal nGrossInc As String, _
                          ByVal dtEmplStartDate As String, _
                          ByVal nLossAss As String, _
                          ByVal sPrevDir As String, _
                          ByVal nEstExp As String, _
                          ByVal nTaxPayable As String, _
                          ByVal nFixedPayMonth As String, _
                          ByRef nReqNo As String) As String
                          

    Dim cmd As ADODB.Command
    
    Dim cnSaveFormIRP3C As ADODB.Connection
    
    
    
    Dim parm As ADODB.Parameter
    
    Set cnSaveFormIRP3C = New ADODB.Connection
    
    
    Set cmd = CreateObject("ADODB.COMMAND")
    
    With cnSaveFormIRP3C
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    
    cmd.CommandText = "dir_load_form_IRP3C"
    cmd.CommandType = adCmdStoredProc
    cmd.ActiveConnection = cnSaveFormIRP3C
    
    
        
        With cmd
            .Parameters.Append cmd.CreateParameter("@username", adVarChar, adParamInput, 10, IIf(Username = "", Null, Username))
            .Parameters.Append cmd.CreateParameter("@scod_no_it_no_rsn", adVarChar, adParamInput, 2, IIf(sNoTaxRefNoRsn = "", Null, sNoTaxRefNoRsn))
            .Parameters.Append cmd.CreateParameter("@no_it_no_text", adVarChar, adParamInput, 65, IIf(sNoTaxRefNoText = "", Null, sNoTaxRefNoText))
            .Parameters.Append cmd.CreateParameter("@income_tax_reference_number", adDouble, adParamInput, , IIf(nIncomeTaxReferenceNo = "", Null, nIncomeTaxReferenceNo))
            .Parameters.Append cmd.CreateParameter("@rsa_id_number", adDouble, adParamInput, , IIf(nRSAID = "", Null, nRSAID))
            .Parameters.Append cmd.CreateParameter("@other_id_number", adVarChar, adParamInput, 15, IIf(sOtherID = "", Null, sOtherID))
            
            'tax payer details
            .Parameters.Append cmd.CreateParameter("@surname", adVarChar, adParamInput, 120, IIf(sSurname = "", Null, sSurname))
            .Parameters.Append cmd.CreateParameter("@initials", adVarChar, adParamInput, 5, IIf(sInitials = "", Null, sInitials))
            .Parameters.Append cmd.CreateParameter("@firstnames", adVarChar, adParamInput, 90, IIf(sFirstNames = "", Null, sFirstNames))
            .Parameters.Append cmd.CreateParameter("@birthdate", adDBTimeStamp, adParamInput, , IIf(dtBirthDate = "", Null, dtBirthDate))
            
            'postal address
            .Parameters.Append cmd.CreateParameter("@post_addr_l1", adVarChar, adParamInput, 35, IIf(sPost1 = "", Null, sPost1))
            .Parameters.Append cmd.CreateParameter("@post_addr_l2", adVarChar, adParamInput, 35, IIf(sPost2 = "", Null, sPost2))
            .Parameters.Append cmd.CreateParameter("@post_addr_l3", adVarChar, adParamInput, 35, IIf(sPost3 = "", Null, sPost3))
            .Parameters.Append cmd.CreateParameter("@post_addr_l4", adVarChar, adParamInput, 35, IIf(sPost4 = "", Null, sPost4))
            .Parameters.Append cmd.CreateParameter("@post_postal_code", adVarChar, adParamInput, 10, IIf(sPostCode = "", Null, sPostCode))
            
            'residential address
            .Parameters.Append cmd.CreateParameter("@home_addr_l1", adVarChar, adParamInput, 35, IIf(sHome1 = "", Null, sHome1))
            .Parameters.Append cmd.CreateParameter("@home_addr_l2", adVarChar, adParamInput, 35, IIf(sHome2 = "", Null, sHome2))
            .Parameters.Append cmd.CreateParameter("@home_addr_l3", adVarChar, adParamInput, 35, IIf(sHome3 = "", Null, sHome3))
            .Parameters.Append cmd.CreateParameter("@home_addr_l4", adVarChar, adParamInput, 35, IIf(sHome4 = "", Null, sHome4))
            .Parameters.Append cmd.CreateParameter("@home_postal_code", adVarChar, adParamInput, 5, IIf(sHomeCode = "", Null, sHomeCode))
            
            'some other details
            .Parameters.Append cmd.CreateParameter("@tax_year", adDouble, adParamInput, 0, IIf(nTaxYear = "", Null, nTaxYear))
            .Parameters.Append cmd.CreateParameter("@scod_req_rsn", adVarChar, adParamInput, 2, IIf(lstRFD = "", Null, lstRFD))
            
            'IRP3C specific details
            .Parameters.Append cmd.CreateParameter("@annual_salary", adDouble, adParamInput, , IIf(nTaxPayersAnnualIncome = "", Null, nTaxPayersAnnualIncome))
            .Parameters.Append cmd.CreateParameter("@prev_dir_yn", adVarChar, adParamInput, 1, IIf(sPrevDir = "", Null, sPrevDir))
            .Parameters.Append cmd.CreateParameter("@tax_payable", adDouble, adParamInput, , IIf(nTaxPayable = "", Null, nTaxPayable))
            .Parameters.Append cmd.CreateParameter("@amount_required", adDouble, adParamInput, , IIf(nFixedPayMonth = "", Null, nFixedPayMonth))
            .Parameters.Append cmd.CreateParameter("@est_gross_income", adDouble, adParamInput, , IIf(nGrossInc = "", Null, nGrossInc))
            .Parameters.Append cmd.CreateParameter("@est_expenditure", adDouble, adParamInput, , IIf(nEstExp = "", Null, nEstExp))
            .Parameters.Append cmd.CreateParameter("@assessed_loss", adDouble, adParamInput, , IIf(nLossAss = "", Null, nLossAss))
            .Parameters.Append cmd.CreateParameter("@employment_start_date", adDBTimeStamp, adParamInput, , IIf(dtEmplStartDate = "", Null, dtEmplStartDate))
            
            'this field is in the IRP3CS Table, but not anywhere else
            '.Parameters.Append cmd.CreateParameter("@assess_loss", adDouble, adParamInput, , IIf(nLossAss = "", Null, nLossAss))
            
            'other details
            .Parameters.Append cmd.CreateParameter("@emp_id", adDouble, adParamInput, , IIf(nEmpID = "", Null, nEmpID))
            .Parameters.Append cmd.CreateParameter("@email_to", adVarChar, adParamInput, 80, IIf(sEmailTo = "", Null, sEmailTo))
            .Parameters.Append cmd.CreateParameter("@employee_number", adVarChar, adParamInput, 80, IIf(nEmployeeNo = "", Null, nEmployeeNo))
            
            .Parameters.Append cmd.CreateParameter("@req_seq_num", adDouble, adParamOutput)
    End With
        
    
    On Error Resume Next
    
    cmd.Execute
    
    Select Case Err.Number
        Case 0
            nReqNo = CStr(cmd.Parameters.Item("@req_seq_num").Value)
            SaveIRP3C = "Request " & cmd.Parameters("@req_seq_num") & " " & "Successfully saved."
        Case Else
            SaveIRP3C = "WARNING: Your request has NOT been saved.  Please re-submit your request. <br><br><b>Error Information</b> <br><br> Error Number: " & Err.Number & " <br><br> Error description: <br>" & Err.Description & ""
    End Select
    


'clean up
cnSaveFormIRP3C.Close
Set cnSaveFormIRP3C = Nothing
End Function

Public Function SaveOtherLosses(ByVal nReqNumber As String, ByVal nLossNature As String, ByVal nLossAmount As String) As String

On Error GoTo PROC_ERROR

    Dim cnConnection As ADODB.Connection
    Dim rsRecordSet As ADODB.recordSet
    
    
    Dim cmd As ADODB.Command
    
    
    Set cnConnection = New ADODB.Connection
    
    With cnConnection
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    Set rsRecordSet = New ADODB.recordSet
        
    Set cmd = New ADODB.Command
    cmd.CommandText = "dir_insert_other_loss"
    cmd.CommandType = adCmdStoredProc
    cmd.ActiveConnection = cnConnection
        
        cmd.Parameters.Append cmd.CreateParameter("req_seq_num", adDouble, adParamInput, , IIf(nReqNumber = "", Null, nReqNumber))
        cmd.Parameters.Append cmd.CreateParameter("loss_nature", adVarChar, adParamInput, 20, nLossNature)
        cmd.Parameters.Append cmd.CreateParameter("loss_amount", adDouble, adParamInput, , nLossAmount)
        
    Set rsRecordSet = cmd.Execute
    
    cnConnection.Close
    Set cnConnection = Nothing

PROC_EXIT:
  
  SaveOtherLosses = "Saved"
  
  Exit Function
  
PROC_ERROR:
  Err.Raise Err.Number, "SaveOtherLosses", _
            "Failed to insert other amount values." & vbCrLf & _
            "Description: " & Err.Description
  GoTo PROC_EXIT
  
End Function


